package com.br.aiops.receiver;

import com.br.aiops.counter.Counter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

/**
 * 接收告警
 */
@RestController
@RequestMapping("/api/receive")
public class AlertLogHttpReceiver {

    @Autowired
    private Counter counter;

    @PostMapping
    public void receive(@RequestBody AlertLog alertLog) {
        alertLog.setLogTime(new Date());
        counter.count(alertLog);
    }
}
